数组的初始化规则

    int array[3];
    array[0] = 3;
    array[1] = 4;
    array[2] = 5;

    int b[4] = {1,2,3,4};

    std::cout << "size :" << sizeof(array) << std::endl;
    std::cout << "length :" << sizeof(array)/sizeof(int) << std::endl;

    int hand[3];
    //hand = {1,2,3}; not allow
    //hand = array;   not allow

    long totals[500] = {1}; // 第一个元素为1,编译器将把其他元素设置为0;

    short things[] = {1,3,4,5}; // 编辑器将自动计算元素个数

🔚